package com.junjie.blibli.api;

import com.junjie.blibli.Entity.auth.UserAuthorities;
import com.junjie.blibli.Support.UserSupport;
import com.junjie.blibli.result.JsonResponse;
import com.junjie.blibli.service.UserAuthService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class UserAuthApi {
    @Autowired
    private UserSupport userSupport;

    @Autowired
    private UserAuthService userAuthService;

    //前端需要知道用户有多少页面权限和操作权限
    @GetMapping("/user-authories")
    public JsonResponse<UserAuthorities> getUserAuthorities(){
        Long userId = userSupport.getCurrentUserId();
        UserAuthorities userAuthorities = userAuthService.getUserAuthorities(userId);
        return new JsonResponse<>(userAuthorities);
    }
}
